package utils

import (
	"crypto/md5"
	"fmt"
	"gspeed/bootstrap/global"
	"text/template"
)

func Md5(str string) string {
	data := []byte(str)
	has := md5.Sum(data)
	return fmt.Sprintf("%x", has) //将[]byte转成16进制
}

func Md5WithSalt(str string) string {
	str = global.Config.GetString("app.key") + str
	return Md5(str)
}

func Xss(text string) string {
	text = template.HTMLEscaper(text)
	text = template.JSEscaper(text)
	return text
}
